// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.IndexManagement
{
	public sealed partial class IndexRoutingAllocation
	{
		[JsonInclude]
		[JsonPropertyName("disk")]
		public Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationDisk? Disk { get; set; }

		[JsonInclude]
		[JsonPropertyName("enable")]
		public Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationOptions? Enable { get; set; }

		[JsonInclude]
		[JsonPropertyName("include")]
		public Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationInclude? Include { get; set; }

		[JsonInclude]
		[JsonPropertyName("initial_recovery")]
		public Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationInitialRecovery? InitialRecovery { get; set; }
	}

	public sealed partial class IndexRoutingAllocationDescriptor : SerializableDescriptorBase<IndexRoutingAllocationDescriptor>
	{
		internal IndexRoutingAllocationDescriptor(Action<IndexRoutingAllocationDescriptor> configure) => configure.Invoke(this);
		public IndexRoutingAllocationDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationDisk? DiskValue { get; set; }

		private IndexRoutingAllocationDiskDescriptor DiskDescriptor { get; set; }

		private Action<IndexRoutingAllocationDiskDescriptor> DiskDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationOptions? EnableValue { get; set; }

		private Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationInclude? IncludeValue { get; set; }

		private IndexRoutingAllocationIncludeDescriptor IncludeDescriptor { get; set; }

		private Action<IndexRoutingAllocationIncludeDescriptor> IncludeDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationInitialRecovery? InitialRecoveryValue { get; set; }

		private IndexRoutingAllocationInitialRecoveryDescriptor InitialRecoveryDescriptor { get; set; }

		private Action<IndexRoutingAllocationInitialRecoveryDescriptor> InitialRecoveryDescriptorAction { get; set; }

		public IndexRoutingAllocationDescriptor Disk(Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationDisk? disk)
		{
			DiskDescriptor = null;
			DiskDescriptorAction = null;
			DiskValue = disk;
			return Self;
		}

		public IndexRoutingAllocationDescriptor Disk(IndexRoutingAllocationDiskDescriptor descriptor)
		{
			DiskValue = null;
			DiskDescriptorAction = null;
			DiskDescriptor = descriptor;
			return Self;
		}

		public IndexRoutingAllocationDescriptor Disk(Action<IndexRoutingAllocationDiskDescriptor> configure)
		{
			DiskValue = null;
			DiskDescriptor = null;
			DiskDescriptorAction = configure;
			return Self;
		}

		public IndexRoutingAllocationDescriptor Enable(Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationOptions? enable)
		{
			EnableValue = enable;
			return Self;
		}

		public IndexRoutingAllocationDescriptor Include(Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationInclude? include)
		{
			IncludeDescriptor = null;
			IncludeDescriptorAction = null;
			IncludeValue = include;
			return Self;
		}

		public IndexRoutingAllocationDescriptor Include(IndexRoutingAllocationIncludeDescriptor descriptor)
		{
			IncludeValue = null;
			IncludeDescriptorAction = null;
			IncludeDescriptor = descriptor;
			return Self;
		}

		public IndexRoutingAllocationDescriptor Include(Action<IndexRoutingAllocationIncludeDescriptor> configure)
		{
			IncludeValue = null;
			IncludeDescriptor = null;
			IncludeDescriptorAction = configure;
			return Self;
		}

		public IndexRoutingAllocationDescriptor InitialRecovery(Elastic.Clients.Elasticsearch.IndexManagement.IndexRoutingAllocationInitialRecovery? initialRecovery)
		{
			InitialRecoveryDescriptor = null;
			InitialRecoveryDescriptorAction = null;
			InitialRecoveryValue = initialRecovery;
			return Self;
		}

		public IndexRoutingAllocationDescriptor InitialRecovery(IndexRoutingAllocationInitialRecoveryDescriptor descriptor)
		{
			InitialRecoveryValue = null;
			InitialRecoveryDescriptorAction = null;
			InitialRecoveryDescriptor = descriptor;
			return Self;
		}

		public IndexRoutingAllocationDescriptor InitialRecovery(Action<IndexRoutingAllocationInitialRecoveryDescriptor> configure)
		{
			InitialRecoveryValue = null;
			InitialRecoveryDescriptor = null;
			InitialRecoveryDescriptorAction = configure;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (DiskDescriptor is not null)
			{
				writer.WritePropertyName("disk");
				JsonSerializer.Serialize(writer, DiskDescriptor, options);
			}
			else if (DiskDescriptorAction is not null)
			{
				writer.WritePropertyName("disk");
				JsonSerializer.Serialize(writer, new IndexRoutingAllocationDiskDescriptor(DiskDescriptorAction), options);
			}
			else if (DiskValue is not null)
			{
				writer.WritePropertyName("disk");
				JsonSerializer.Serialize(writer, DiskValue, options);
			}

			if (EnableValue is not null)
			{
				writer.WritePropertyName("enable");
				JsonSerializer.Serialize(writer, EnableValue, options);
			}

			if (IncludeDescriptor is not null)
			{
				writer.WritePropertyName("include");
				JsonSerializer.Serialize(writer, IncludeDescriptor, options);
			}
			else if (IncludeDescriptorAction is not null)
			{
				writer.WritePropertyName("include");
				JsonSerializer.Serialize(writer, new IndexRoutingAllocationIncludeDescriptor(IncludeDescriptorAction), options);
			}
			else if (IncludeValue is not null)
			{
				writer.WritePropertyName("include");
				JsonSerializer.Serialize(writer, IncludeValue, options);
			}

			if (InitialRecoveryDescriptor is not null)
			{
				writer.WritePropertyName("initial_recovery");
				JsonSerializer.Serialize(writer, InitialRecoveryDescriptor, options);
			}
			else if (InitialRecoveryDescriptorAction is not null)
			{
				writer.WritePropertyName("initial_recovery");
				JsonSerializer.Serialize(writer, new IndexRoutingAllocationInitialRecoveryDescriptor(InitialRecoveryDescriptorAction), options);
			}
			else if (InitialRecoveryValue is not null)
			{
				writer.WritePropertyName("initial_recovery");
				JsonSerializer.Serialize(writer, InitialRecoveryValue, options);
			}

			writer.WriteEndObject();
		}
	}
}